package com.saihai.jiankang.selectItem.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.saihai.common.annotation.Log;
import com.saihai.common.core.controller.BaseController;
import com.saihai.common.core.domain.AjaxResult;
import com.saihai.common.enums.BusinessType;
import com.saihai.jiankang.selectItem.domain.WorkflowSelectitem;
import com.saihai.jiankang.selectItem.service.IWorkflowSelectitemService;
import com.saihai.common.utils.poi.ExcelUtil;
import com.saihai.common.core.page.TableDataInfo;

/**
 * 字典Controller
 * 
 * @author ruoyi
 * @date 2024-07-01
 */
@RestController
@RequestMapping("/jiankang/SelectItem")
public class WorkflowSelectitemController extends BaseController
{
    @Autowired
    private IWorkflowSelectitemService workflowSelectitemService;

    /**
     * 查询字典列表
     */
    @PreAuthorize("@ss.hasPermi('jiankang:SelectItem:list')")
    @GetMapping("/list")
    public TableDataInfo list(WorkflowSelectitem workflowSelectitem)
    {
        startPage();
        List<WorkflowSelectitem> list = workflowSelectitemService.selectWorkflowSelectitemList(workflowSelectitem);
        return getDataTable(list);
    }

    /**
     * 导出字典列表
     */
    @PreAuthorize("@ss.hasPermi('jiankang:SelectItem:export')")
    @Log(title = "字典", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WorkflowSelectitem workflowSelectitem)
    {
        List<WorkflowSelectitem> list = workflowSelectitemService.selectWorkflowSelectitemList(workflowSelectitem);
        ExcelUtil<WorkflowSelectitem> util = new ExcelUtil<WorkflowSelectitem>(WorkflowSelectitem.class);
        util.exportExcel(response, list, "字典数据");
    }

    /**
     * 获取字典详细信息
     */
    @PreAuthorize("@ss.hasPermi('jiankang:SelectItem:query')")
    @GetMapping(value = "/{fieldid}")
    public AjaxResult getInfo(@PathVariable("fieldid") Long fieldid)
    {
        return success(workflowSelectitemService.selectWorkflowSelectitemByFieldid(fieldid));
    }

    /**
     * 新增字典
     */
    @PreAuthorize("@ss.hasPermi('jiankang:SelectItem:add')")
    @Log(title = "字典", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WorkflowSelectitem workflowSelectitem)
    {
        return toAjax(workflowSelectitemService.insertWorkflowSelectitem(workflowSelectitem));
    }

    /**
     * 修改字典
     */
    @PreAuthorize("@ss.hasPermi('jiankang:SelectItem:edit')")
    @Log(title = "字典", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WorkflowSelectitem workflowSelectitem)
    {
        return toAjax(workflowSelectitemService.updateWorkflowSelectitem(workflowSelectitem));
    }

    /**
     * 删除字典
     */
    @PreAuthorize("@ss.hasPermi('jiankang:SelectItem:remove')")
    @Log(title = "字典", businessType = BusinessType.DELETE)
	@DeleteMapping("/{fieldids}")
    public AjaxResult remove(@PathVariable Long[] fieldids)
    {
        return toAjax(workflowSelectitemService.deleteWorkflowSelectitemByFieldids(fieldids));
    }
}
